import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/locale_tool.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'logic.dart';

class QuestionPage extends StatelessWidget {
  QuestionPage({Key? key}) : super(key: key);

  final logic = Get.put(QuestionLogic());
  final state = Get.find<QuestionLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.question.ts, style: TextStyle(fontSize: 54.sp, color: ColorConst.btnFontColor),),
        centerTitle: true,
        leading: BackBtnIcon(onTap: () => Get.back()),
        //   leading: IconButton(
        //     padding: EdgeInsets.only(left: 15,),
        //     icon: Image.asset("assets/images/space/icon_appbar_arrow_back.png"),
        //     onPressed: () { Get.back(); },
        //   ),
        //   leadingWidth: 25,
      ),
      body: ListView(
        children: [
          Container(
            padding: EdgeInsets.fromLTRB(42.w, 100.h, 42.w, 240.h),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                // GestureDetector(
                //   behavior: HitTestBehavior.opaque,
                //   onTap: (){},
                //   child: Container(
                //     margin: EdgeInsets.only(top: 38.h, bottom: 82.h),
                //     padding: EdgeInsets.fromLTRB(62.w, 50.h, 56.w, 50.h),
                //     decoration: BoxDecoration(
                //         borderRadius: BorderRadius.circular(10),
                //         color: Colors.white
                //     ),
                //     child: Row(
                //       mainAxisAlignment: MainAxisAlignment.spaceBetween,
                //       children: [
                //         Text(LocaleKeys.question_tips.ts, style: TextStyle(fontSize: 42.sp, color: ColorConst.btnFontColor,)),
                //         Image(
                //             width: 36.w,
                //             height: 21.h,
                //             image: const AssetImage("assets/images/device/icon_restoration_arrow.png"))
                //       ],
                //     ),
                //   ),
                // ),
                // Text('APP搜索不到设备', style: TextStyle(fontSize: 54.sp, color: ColorConst.btnFontColor),),
                // SizedBox(height: 58.h,),
                Container(
                  child: Column(
                    children: [
                      _buildListTile(LocaleKeys.question_01.ts, '', true, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_01.ts,'answer':LocaleKeys.answer_01.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_02.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_02.ts,'answer':LocaleKeys.answer_02.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_03.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_03.ts,'answer':LocaleKeys.answer_03.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_04.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_04.ts,'answer':LocaleKeys.answer_04.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_05.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_05.ts,'answer':LocaleKeys.answer_05.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_06.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_06.ts,'answer':LocaleKeys.answer_06.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_07.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_07.ts,'answer':LocaleKeys.answer_07.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_08.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_08.ts,'answer':LocaleKeys.answer_08.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_09.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_09.ts,'answer':LocaleKeys.answer_09.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_10.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_10.ts,'answer':LocaleKeys.answer_10.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_11.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_11.ts,'answer':LocaleKeys.answer_11.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_12.ts, '', false, false, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_12.ts,'answer':LocaleKeys.answer_12.ts});}),
                      Divider(height: 1.h,),
                      _buildListTile(LocaleKeys.question_13.ts, '', false, LocaleTool.locale.contains('en'), onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_13.ts,'answer':LocaleKeys.answer_13.ts});}),
                      Offstage(
                        offstage: LocaleTool.locale.contains('en'),
                        child: Divider(height: 1.h,),
                      ),
                      Offstage(
                        offstage: LocaleTool.locale.contains('en'),
                        child: _buildListTile(LocaleKeys.question_14.ts, '', false, true, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_14.ts,'answer':LocaleKeys.answer_14.ts});}),
                      ),
                      Offstage(
                        offstage: LocaleTool.locale.contains('en'),
                        child: Divider(height: 1.h,),
                      ),
                      Offstage(
                        offstage: LocaleTool.locale.contains('en'),
                        child: _buildListTile(LocaleKeys.question_15.ts, '', false, true, onTap: (){Get.toNamed('/space/question', arguments: {'question':LocaleKeys.question_15.ts,'answer':LocaleKeys.answer_15.ts});}),
                      ),
                    ],
                  ),
                )
              ],
            ),)
        ],),);
  }

  Widget _buildListTile(
      String title, String trailing,isFirst, isLast, {onTap}) {
    var borderRadius = BorderRadius.circular(0);
    if (isFirst && !isLast) {
      borderRadius = const BorderRadius.vertical(top: Radius.circular(10));
    } else if (!isFirst && isLast) {
      borderRadius = const BorderRadius.vertical(bottom: Radius.circular(10));
    } else if (isFirst && isLast) {
      borderRadius = BorderRadius.circular(10);
    }

    return Ink(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: borderRadius,
      ),
      child: InkResponse(
        onTap: onTap,
        splashColor: ColorConst.activeColor,
        borderRadius: borderRadius,
        highlightShape: BoxShape.rectangle,
        highlightColor: ColorConst.activeColor,
        containedInkWell: true,
        child: ListTile(
          contentPadding: EdgeInsets.fromLTRB(40.w, 0, 40.w, 0),
          title: Text(title, style: TextStyle(fontSize: 48.sp)),
          trailing: Icon(
            Icons.arrow_forward_ios,
            size: 16,
          ),),
      ),
    );
  }
}
